package com.yksj.healthtalk.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yksj.healthtalk.ui.R;

public class CustomerselfProblemAdapter extends BaseAdapter{
	private Context context;
	private LayoutInflater inflater;
//	String format;
	
	public  CustomerselfProblemAdapter(Context context){
		this.context = context;
		inflater  = LayoutInflater.from(context);
//		format = context.getResources().getString(R.string.problem_support);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 5;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = inflater.inflate(R.layout.problem_customerself_item, null);
			holder.questionTime = (TextView) convertView.findViewById(R.id.questionTime);
			holder.header = (ImageView)convertView.findViewById(R.id.header);
			holder.name = (TextView)convertView.findViewById(R.id.name);
			holder.answer = (TextView) convertView.findViewById(R.id.answer);
			holder.newAnswer = (TextView) convertView.findViewById(R.id.new_answer);
			convertView.setTag(holder);
		}else {
			holder = 	(ViewHolder) convertView.getTag();
		}
		
		if (position == 0) {
			holder.newAnswer.setVisibility(View.VISIBLE);
			holder.answer.setText("已回复");
			holder.answer.setBackgroundResource(R.drawable.answered);
		}else if(position == 1) {
			holder.newAnswer.setVisibility(View.GONE);
			holder.answer.setText("待回复");
			holder.answer.setBackgroundResource(R.drawable.no_answer);
		}else {
			holder.newAnswer.setVisibility(View.GONE);
			holder.answer.setText("已解决");
			holder.answer.setBackgroundResource(R.drawable.solved);
		}
		
		return convertView;
	}

	
	class ViewHolder{
		TextView  questionTime;
		ImageView  header;
		TextView  name;
		TextView answer;
		TextView newAnswer;
	}

}
